<template>
  <div class="approval">
    <el-card class="box-card" style="margin-top: 110px;">
      <div class="head-title2">
        <div class='title'>
          {{$t('achievements.title1')}}
        </div>
        <div class="info">
          <el-tooltip placement="left">
            <div slot="content">
              {{define}}
            </div>
            <div class="btns"></div>
          </el-tooltip>
        </div>
      </div>
      <div class="menu-search">
        <div class="menu-title">
          <div class='searchItem'>
            <span>{{$t('ElectricChannel.AppChannel')}}</span>
            <el-select v-model='listQuery.channel'  size='small'>
                <el-option
                v-for='item in channelList'
                :key='item.channel'
                :label='item.org_name'
                :value='item.channel'>
                </el-option>
            </el-select>
          </div>
          <div class="menu-title-btn" style="margin-left: 20px;">
            <button type="button" @click="search">{{$t('btn.query')}}</button>
          </div>
        </div>
      </div>
    </el-card>
    <el-card class="box-card" style="margin-top: 10px;">
      <div class="title">{{$t('loanPlanReport.customerCount')}}</div>
      <div>
        <bar-chart :channel="propChannel"></bar-chart>
      </div>
      <div class="title">{{$t('loanPlanReport.customerRate')}}</div>
      <div>
        <line-chart :channel="propChannel"></line-chart>
      </div>
    </el-card>
  </div>
</template>

<script>
import { mapGetters } from 'vuex';
import { getChannels } from 'api/customQuery/index';
// import { getBarGraphCount, getCustomerRateCount } from 'api/reportStatistics/investorReport/index';
export default {
  data() {
    return {
      define: '',
      channelList: [],
      listQuery: {
        // 渠道
        channel: ''
      },
      propChannel: '',
      barData: [],
      lineData: []
    }
  },
  components: {
    'bar-chart': () => import('./echart/barChart'),
    'line-chart': () => import('./echart/lineChart')
  },
  methods: {
    search() {
      this.propChannel = this.listQuery.channel
    }
  },
  computed: {
    ...mapGetters(['element', 'loanPlanReportPage', 'getReportDefine'])
  },
  created() {
    if (this.loanPlanReportPage.has(this.$route.path)) {
      this.listQuery = this.loanPlanReportPage.get(this.$route.path);
    }
    getChannels().then(res => {
      if (res.status === 200) {
        this.channelList = res.data
        this.listQuery.channel = res.data.length > 0 && res.data[0].channel
        this.propChannel = this.listQuery.channel
      }
    })
    // 获取报表定义
    this.getReportDefine.forEach(item => {
      if (item.dictCode === 'LOAN_PLAN_REPORT') {
        this.define = item.dictValue
      }
    })
  }
}
</script>

<style scoped lang='scss'>
.box-card {
  width: 95%;
  margin-left: 2.5%;
  margin-right: 2.5%;
}
.title {
  line-height: 30px;
  font-size: 16px;
  display: flex;
  align-items: center;
  font-weight: bold;
}
.title:before {
  display: block;
  content: '';
  width: 3px;
  height: 16px;
  background-color: #309afe;
}
.title:before {
  margin-right: 8px;
}
::before {
  box-sizing: inherit;
  -webkit-tap-highlight-color: transparent;
}
.menu-title {
  width: 100%;
  box-sizing: border-box;
  background: #ffffff;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  .searchItem {
    display: flex;
    align-items: center;
    padding: 10px 0;
    span {
      display: inline-block;
      width: 100px;
      text-align: right;
      font-size: 12px;
      color: #5f5f61;
      padding-right: 5px;
    }
    div:nth-child(2) {
      width: 150px;
    }
    &.radioGroup {
      div:nth-child(2) {
        width: auto;
      }
    }
  }
  // .searchItem-date {
  //   display: flex;
  //   align-items: center;
  //   padding: 10px 0;
  //   span {
  //     display: inline-block;
  //     width: 100px;
  //     text-align: right;
  //     font-size: 12px;
  //     color: #5f5f61;
  //     padding-right: 5px;
  //   }
  //   div:nth-child(2) {
  //     width: 220px;
  //   }
  // }
  .searchItem-date {
    display: flex;
    align-items: center;
    padding: 10px  0;
    b {
      margin: 0 10px;
      font-weight: normal;
      font-size: 12px;
      color: #5f5f61;
    }
    div {
       width: 150px;
    }
  }
}
.menu-title-btn {
  padding: 10px 0;
  box-sizing: border-box;
  button {
    padding: 0 20px;
    height: 28px;
    background: #20a0ff;
    color: #fff;
    outline: none;
    border-width: 0;
    border-radius: 4px;
    font-size: 12px;
    margin-left: 10px;
    &:nth-child(1) {
      margin-left: 0;
    }
    &:nth-child(2) {
      background: #ebf5ff;
      color: #20a0ff;
      border: 1px solid #abd5ff;
    }
  }
  button[disabled] {
    padding: 0 20px;
    height: 28px;
    background: #c1e0ff;
    color: #fafbff;
    outline: none;
    border-width: 0;
    border-radius: 4px;
    font-size: 12px;
  }
}
.menu-list {
  padding: 20px 0;
  box-sizing: border-box;
  button {
    padding: 0 20px;
    height: 28px;
    background: #20a0ff;
    color: #fff;
    outline: none;
    border-width: 0;
    border-radius: 4px;
    font-size: 12px;
    margin-left: 10px;
    &:nth-child(1) {
      margin-left: 0;
    }
  }
  button[disabled] {
    padding: 0 20px;
    height: 28px;
    background: #c1e0ff;
    color: #fafbff;
    outline: none;
    border-width: 0;
    border-radius: 4px;
    font-size: 12px;
  }
}
.chart {
  width: 100%;
  height: 400px;
}
.head-title2 {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.btns {
  display: inline-block;
  width: 24px;
  height: 24px;
  background-size: cover;
  background-image: url("../../../../assets/images/question-mark.svg");
}
</style>